home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri K-CD 2002 #1 / K-CD_2002-01.iso / Delphi / INSTALL / program files / Borland / Delphi6 / Doc / ActnList.int next >
Encoding:
Text File  |  2001-05-22  |  6.8 KB  |  197 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {  Copyright (c) 1999-2001 Borland Software Corporation }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit ActnList;
  11.  
  12. {$T-,H+,X+}
  13.  
  14. interface
  15.  
  16. uses Classes, Messages, ImgList, Contnrs;
  17.  
  18. type
  19.  
  20. { TContainedAction }
  21.  
  22.   TCustomActionList = class;
  23.  
  24.   TContainedAction = class(TBasicAction)
  25.   protected
  26.     procedure ReadState(Reader: TReader); override;
  27.     procedure SetParentComponent(AParent: TComponent); override;
  28.   public
  29.     destructor Destroy; override;
  30.     function Execute: Boolean; override;
  31.     function GetParentComponent: TComponent; override;
  32.     function HasParent: Boolean; override;
  33.     function Update: Boolean; override;
  34.     property ActionList: TCustomActionList;
  35.     property Index: Integer;
  36.   published
  37.     property Category: string;
  38.   end;
  39.  
  40.   TContainedActionClass = class of TContainedAction;
  41.  
  42. { TCustomActionList }
  43.  
  44.   TActionEvent = procedure (Action: TBasicAction; var Handled: Boolean) of object;
  45.   TActionListState = (asNormal, asSuspended, asSuspendedEnabled);
  46.  
  47.   TCustomActionList = class(TComponent)
  48.   protected
  49.     procedure AddAction(Action: TContainedAction);
  50.     procedure RemoveAction(Action: TContainedAction);
  51.     procedure Change; virtual;
  52.     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  53.     procedure Notification(AComponent: TComponent;
  54.       Operation: TOperation); override;
  55.     procedure SetChildOrder(Component: TComponent; Order: Integer); override;
  56.     procedure SetImages(Value: TCustomImageList); virtual;
  57.     property OnChange: TNotifyEvent;
  58.     property OnExecute: TActionEvent;
  59.     property OnUpdate: TActionEvent;
  60.   public
  61.     constructor Create(AOwner: TComponent); override;
  62.     destructor Destroy; override;
  63.     function ExecuteAction(Action: TBasicAction): Boolean; override;
  64.     function IsShortCut(var Message: TWMKey): Boolean;
  65.     function UpdateAction(Action: TBasicAction): Boolean; override;
  66.     property Actions[Index: Integer]: TContainedAction; default;
  67.     property ActionCount: Integer;
  68.     property Images: TCustomImageList;
  69.     property State: TActionListState default asNormal;
  70.   end;
  71.  
  72. { TActionList }
  73.  
  74.   TActionList = class(TCustomActionList)
  75.   published
  76.     property Images;
  77.     property State;
  78.     property OnChange;
  79.     property OnExecute;
  80.     property OnUpdate;
  81.   end;
  82.  
  83. { TShortCutList }
  84.  
  85.   TShortCutList = class(TStringList)
  86.   public
  87.     function Add(const S: String): Integer; override;
  88.     function IndexOfShortCut(const Shortcut: TShortCut): Integer;
  89.     property ShortCuts[Index: Integer]: TShortCut;
  90.   end;
  91.  
  92. { TControlAction }
  93.  
  94.   THintEvent = procedure (var HintStr: string; var CanShow: Boolean) of object;
  95.  
  96.   TCustomAction = class(TContainedAction)
  97.   protected
  98.     FImage: TObject;
  99.     FMask: TObject;
  100.     procedure AssignTo(Dest: TPersistent); override;
  101.     procedure SetName(const Value: TComponentName); override;
  102.     function HandleShortCut: Boolean; virtual;
  103.     property SavedEnabledState: Boolean;
  104.   public
  105.     constructor Create(AOwner: TComponent); override;
  106.     destructor Destroy; override;
  107.     function DoHint(var HintStr: string): Boolean; dynamic;
  108.     function Execute: Boolean; override;
  109.     property AutoCheck: Boolean default False;
  110.     property Caption: string;
  111.     property Checked: Boolean default False;
  112.     property DisableIfNoHandler: Boolean default False;
  113.     property Enabled: Boolean default True;
  114.     property GroupIndex: Integer default 0;
  115.     property HelpContext: THelpContext default 0;
  116.     property HelpKeyword: string;
  117.     property HelpType: THelpType default htKeyword;
  118.     property Hint: string;
  119.     property ImageIndex: TImageIndex default -1;
  120.     property ShortCut: TShortCut default 0;
  121.     property SecondaryShortCuts: TShortCutList;
  122.     property Visible: Boolean default True;
  123.     property OnHint: THintEvent;
  124.   end;
  125.  
  126.   TAction = class(TCustomAction)
  127.   public
  128.     constructor Create(AOwner: TComponent); override;
  129.   published
  130.     property AutoCheck;
  131.     property Caption;
  132.     property Checked;
  133.     property Enabled;
  134.     property GroupIndex;
  135.     property HelpContext;
  136.     property HelpKeyword;
  137.     property HelpType;
  138.     property Hint;
  139.     property ImageIndex;
  140.     property ShortCut;
  141.     property SecondaryShortCuts;
  142.     property Visible;
  143.     property OnExecute;
  144.     property OnHint;
  145.     property OnUpdate;
  146.   end;
  147.  
  148. { TActionLink }
  149.  
  150.   TActionLink = class(TBasicActionLink)
  151.   protected
  152.     function IsCaptionLinked: Boolean; virtual;
  153.     function IsCheckedLinked: Boolean; virtual;
  154.     function IsEnabledLinked: Boolean; virtual;
  155.     function IsGroupIndexLinked: Boolean; virtual;
  156.     function IsHelpContextLinked: Boolean; virtual;
  157.     function IsHelpLinked: Boolean; virtual;
  158.     function IsHintLinked: Boolean; virtual;
  159.     function IsImageIndexLinked: Boolean; virtual;
  160.     function IsShortCutLinked: Boolean; virtual;
  161.     function IsVisibleLinked: Boolean; virtual;
  162.     procedure SetAutoCheck(Value: Boolean); virtual;
  163.     procedure SetCaption(const Value: string); virtual;
  164.     procedure SetChecked(Value: Boolean); virtual;
  165.     procedure SetEnabled(Value: Boolean); virtual;
  166.     procedure SetGroupIndex(Value: Integer); virtual;
  167.     procedure SetHelpContext(Value: THelpContext); virtual;
  168.     procedure SetHelpKeyword(const Value: string); virtual;
  169.     procedure SetHelpType(Value: THelpType); virtual;
  170.     procedure SetHint(const Value: string); virtual;
  171.     procedure SetImageIndex(Value: Integer); virtual;
  172.     procedure SetShortCut(Value: TShortCut); virtual;
  173.     procedure SetVisible(Value: Boolean); virtual;
  174.   end;
  175.  
  176.   TActionLinkClass = class of TActionLink;
  177.  
  178. { Action registration }
  179.  
  180.   TEnumActionProc = procedure (const Category: string; ActionClass: TBasicActionClass;
  181.     Info: Pointer) of object;
  182.  
  183. procedure RegisterActions(const CategoryName: string;
  184.   const AClasses: array of TBasicActionClass; Resource: TComponentClass);
  185. procedure UnRegisterActions(const AClasses: array of TBasicActionClass);
  186. procedure EnumRegisteredActions(Proc: TEnumActionProc; Info: Pointer);
  187. function CreateAction(AOwner: TComponent; ActionClass: TBasicActionClass): TBasicAction;
  188.  
  189. const
  190.   RegisterActionsProc: procedure (const CategoryName: string;
  191.     const AClasses: array of TBasicActionClass; Resource: TComponentClass) = nil;
  192.   UnRegisterActionsProc: procedure (const AClasses: array of TBasicActionClass) = nil;
  193.   EnumRegisteredActionsProc: procedure (Proc: TEnumActionProc; Info: Pointer) = nil;
  194.   CreateActionProc: function (AOwner: TComponent; ActionClass: TBasicActionClass): TBasicAction = nil;
  195.  
  196. implementation
  197.